home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / icons+tools / iconian / sources / emodules / mod / ports.e < prev    next >
Text File  |  1995-12-22  |  1KB  |  68 lines

  1. OPT MODULE
  2. MODULE    'exec/ports','exec/nodes'
  3. MODULE    'intuition/intuition'
  4. MODULE    'exec/lists','exec/nodes','exec/ports','exec/memory'
  5.  
  6. EXPORT PROC createPort(portname,priority)
  7.   DEF port=NIL:PTR TO mp
  8.   DEF node=NIL:PTR TO ln
  9.   IF portname
  10.     Forbid()
  11.     IF FindPort(portname)=0
  12.       IF port:=CreateMsgPort()
  13.         node:=port.ln
  14.         node.name:=portname
  15.         node.pri:=priority
  16.         AddPort(port)
  17.       ENDIF
  18.     ENDIF
  19.     Permit()
  20.   ELSE
  21.     port:=CreateMsgPort()
  22.   ENDIF
  23. ENDPROC port,port.sigbit
  24.  
  25. EXPORT PROC deletePort(port:PTR TO mp)
  26.   DEF node=NIL:PTR TO ln
  27.   DEF msg=NIL:PTR TO mn
  28.   IF port
  29.     node:=port.ln
  30.     IF node.name THEN RemPort(port)
  31.     Forbid()
  32.     WHILE msg:=GetMsg(port) DO ReplyMsg(msg)
  33.     DeleteMsgPort(port)
  34.     Permit()
  35.   ENDIF
  36. ENDPROC
  37.  
  38. EXPORT PROC stripintuimessages(mp:PTR TO mp,win:PTR TO window)
  39.     DEF msg:PTR TO intuimessage
  40.     DEF succ:PTR TO ln
  41.     DEF list:PTR TO lh
  42.  
  43. ->     |-intuimessage |-message |-node(ln)       |-msgport |-node
  44. ->     |              |                          |
  45. ->     |                                         | ->list(lh)->head
  46.  
  47.     list:=mp.msglist
  48.     msg:=list.head
  49.     IF (msg<>0)
  50.         WHILE ((succ:=msg::ln.succ)<>0)
  51.             IF msg.idcmpwindow=win
  52.                 Remove(msg)
  53.                 ReplyMsg(msg)
  54.             ENDIF
  55.             msg:=succ
  56.         ENDWHILE
  57.     ENDIF
  58. ENDPROC
  59.  
  60. EXPORT PROC closewindowsafely(win:PTR TO window)
  61.     Forbid()
  62.     stripintuimessages(win.userport,win)
  63.     win.userport:=NIL
  64.     ModifyIDCMP(win,NIL)
  65.     Permit()
  66.     CloseWindow(win)
  67. ENDPROC
  68.